import axios from '@/utils/service'
import type { ToDo } from '@/stores/types'

// 分页
export function getTodos<T>(page: number, size: number) {
  return axios.get<T, T>(`/api/todo/${page}/${size}`)
}

// 搜索API
export function getTodoListByContent<T>(content: string) {
  return axios.get<T, T>(`/api/todo/${content}`)
}

// 添加note
export function addTodo<T>(note: ToDo) {
  return axios.post<T, T>('/api/todo', note)
}

// 删除note
export function deleteTodo<T>(id: string) {
  return axios.delete(`/api/todo/${id}`)
}

// 修改note
export function updateTodo<T>(id: string, note: ToDo) {
  return axios.put(`/api/todo/${id}`, note)
}
